# -*- coding: utf-8 -*-
# @Time    : 2020/6/5
# @Author  : nanjiang.xie
# @File    : Shell.py

"""
封装执行shell语句方法
"""

import subprocess


def execute_shell(cmd):
    """执行shell脚本

    - :param cmd: 【必填】需要执行的命令，类型：string
    - :return: 返回执行结果
    """
    output, errors = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
    o = output.decode("utf-8")
    return o